<%#
#  Copyright 2009 Swansea University.
# 
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
# 
#       http://www.apache.org/licenses/LICENSE-2.0
# 
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.
#  under the License.
%>

<% title "Rank Your Selected Projects" %>

<% slogan "&ldquo;I have called this principle, by which each slight variation, if useful, is preserved, by the term of Natural Selection&rdquo; &ndash; Charles Darwin, On the Origin of Species (1859)" %>

<% if @project_selection.selected_projects.empty? %>
  <p>You don't appear to have selected any projects yet. Go <%= link_to 'back to selection list', project_selections_path %>?
<% else %>
<p>Here is the current order of your selected projects. One is considered highest.</p>
<p>In this version of <%= proman %>, the ranking tool is rather low-tech. You have to
follow the re-order link, select a new order in the "re-rank" page, and submit.
I am wrking on a more elegent solution, but time ran out. It may be better by the time you read this.</p>



<table>
  <thead>
    <tr>
      <th>Position</th><th>Project title</th><th>Supervisor</th><th>Research Centre</th><th colspan="3">actions</th>
    </tr>
  </thead>
  <tbody>
    <% for selection in @selected_projects %>
      <% project = selection.project %>
      <% user = User.find(project.created_by) %>
      <% supervisor = user.supervisor %>
      <tr class="<%= cycle('even','odd') %>">
        <td><%= selection.position %></td>
        <td><%= link_to project.title, project_selection_selected_project_path(@project_selection, selection) %></td>
        <td><%= user.name %></td>
        <td>
          <% if supervisor %>
            <%= supervisor.research_centre.abbrev %>
          <% else %>
            Undefined
          <% end %>
        </td>
        <td><%= link_to 'Reorder', edit_project_selection_selected_project_path(@project_selection, selection) %>
        <td><%= link_to 'Remove', project_selection_selected_project_path(@project_selection, selection), :confirm => 'Are you sure?', :method => :delete %></td>
      </tr>
    <% end %>
  </tbody>
</table>

<br />

<%= link_to 'Select more projects', edit_project_selection_path(@project_selection) %>
<%= link_to 'See your selections', project_selections_path %>
<% end %>